package tests;

import java.util.LinkedList;

import bookworm.Book;
import bookworm.BooksAndRatingOfOneAuthor;

import visitorpattern.CreatesVisitorsAndVisitsGraph;

public class GetBooksFromSpecificAuthorAndTagTest 
{
	public static void main(String args[])
	{
		PrintTextInJFrame logWindow = new PrintTextInJFrame("log window for graph creation and visitor result");
		
		CreatesVisitorsAndVisitsGraph iteratesSameAuthor = new CreatesVisitorsAndVisitsGraph();
		logWindow.write("now getting books from author Stephenie Meyer");
		BooksAndRatingOfOneAuthor booksAndRating =
				iteratesSameAuthor.getBooksAndAverageRatingOfSpecificAuthorBasedOnTag
																("Stephenie Meyer", "vampires");
		LinkedList<Book> allBooksFromAuthor = booksAndRating.getAllBooksFromAuthor();
		logWindow.write("///start of all books from author Stephenie Meyer////");
		for(int i = 0; i < allBooksFromAuthor.size(); i++)
		{
			Book oneBook = allBooksFromAuthor.get(i);
			String titleOfOneBook = oneBook.getBookName();
			logWindow.write(titleOfOneBook);
		}
		logWindow.write("///end of all books from author Stephenie Meyer///");
		
		logWindow.write("///start of all books from Stephenie Meyer and tag vampires///");
		LinkedList<Book> booksRelatedToTag = booksAndRating.getBooksFromAuthorRelatedToTag();
		for(int j = 0; j < booksRelatedToTag.size(); j++)
		{
			Book oneBook = booksRelatedToTag.get(j);
			String titleOfOneBook = oneBook.getBookName();
			logWindow.write(titleOfOneBook);
		}
		logWindow.write("///end of all books from Stephenie Meyer and tag vampires///");
		
		logWindow.write("stephenie meyer has rating = " +
						booksAndRating.getAverageRatingOfAuthorBasedOnTag() + " based on tag vampires");
	}

}
